package com.question.utils;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

public class StringTools {

	/**
	 * 将题号和答案分割开来
	 * 存储到map集合中，题号为键，答案做值
	 * @param answer
	 * @return
	 */
	public static Map<Integer, String> splitAnswer(String answers){

		MyProperties properties = new MyProperties();
		String regex1 = "[a-zA-Z]";
		String shuzi = answers.replaceAll(regex1, " ");
		String[] num = shuzi.split(" ");
		int[] arr = new int[num.length];
		for(int i=0;i<num.length;i++)
			arr[i]=Integer.valueOf(num[i]);

		
		String regex2 = "\\d{3}|\\d{2}|\\d{1}";
		String zimu = answers.replaceAll(regex2, " ");
		String[] answer = zimu.split(" ");
		
		Map<Integer, String> map = new HashMap<Integer, String>();
		for(int i=0;i<answer.length&& i<arr.length;i++)
			map.put(arr[i], answer[i+1]);
		return map;
	}
	
	public static void main(String[] args) {
		String str = "1A23456";
		Map<Integer, String> map= splitAnswer(str);
		for(int i=1;i<=map.size();i++)
			System.out.println(map.get(i));
	}
}
